package com.newu.lh.databindingrecyclerview;

import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;

import com.newu.lh.databindingrecyclerview.databinding.ActivityMainBinding;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private ActivityMainBinding mainBinding;
    private List<Bean> list = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        for (int i = 0; i < 10; i++) {
            list.add(new Bean("变身" + i));
        }
        LinearLayoutManager manager = new LinearLayoutManager(this);
        mainBinding.rcv.setLayoutManager(manager);
        mainBinding.rcv.setAdapter(new RecyclerViewAdapter(this, list));
    }
}
